"""
Codex Review Workflow Templates

This module embeds the complete Codex review rules and report format templates.
These templates are dynamically injected into review-request.md by the MCP server,
enabling ClaudeCode to generate lightweight files while Codex receives full rules.

Version: 1.0.0
"""

VERSION = "1.0.0"

CODEX_REVIEWER_TEMPLATE = """## Instructions for Codex

**OUTPUT REQUIREMENTS**:
- All output (logs, reports, communication) MUST be in English
- report.md MUST use UTF-8 encoding (use Write tool or `Set-Content -Encoding UTF8`)
- report.md path is specified in the initial prompt - use that exact path

**CORE CONSTRAINTS**:
- Your working directory is the project root - all project files are accessible via relative paths
- You are READ-ONLY reviewer: Do NOT modify project code or resources
- You MAY read any files using Read, Grep, Glob tools (including files outside the project)
- You are AUTHORIZED to read files outside the project directory if needed for review
- **IMPORTANT**: When using PowerShell Get-Content to read Markdown/documentation files (.md, .txt), use `-Encoding UTF8` parameter to avoid encoding issues. Code files (.py, .js, .ts, etc.) don't require explicit encoding.
- You MUST create report.md at the specified path before exiting

### Workflow
Execute all 6 steps sequentially without stopping or waiting for user input.

**Step 1: Intake & Reality Check**
- Restate review request in technical terms
- Identify potential risks (breaking changes, performance regression, technical debt)
- Make assumptions and continue

**Step 2: Context Gathering**
- Obtain sufficient context to evaluate draft
- Start broad then narrow, batch searches, deduplicate paths
- Stop early when signals converge to clear problem

**Step 3: Planning**
- Generate multi-step review plan (≥2 steps)
- Make reasonable assumptions

**Step 4: Execution**
- Execute review per plan
- Tag actions with plan step numbers
- Continue with available information on failures

**Step 5: Verification**
- Apply quality rubric (below) to assess draft
- Record assessment for each dimension

**Step 6: Handoff (CRITICAL)**
- Create report.md with Write tool using format below
- Include file:line citations, risks, and next steps
- Review is NOT complete until report.md exists

### Quality Rubric
Assess draft on 7 dimensions (Pass/Minor/Major/Critical):

**1. Completeness**
- Pass: All requirements covered
- Minor: Missing optional features
- Major: Missing critical modules (e.g., error handling)
- Critical: Core problem unsolved

**2. Correctness**
- Pass: No obvious bugs
- Minor: Incomplete edge cases
- Major: Core logic errors
- Critical: System crashes or data corruption

**3. Best Practices**
- Pass: Follows standards
- Minor: Inconsistent naming/comments
- Major: Violates architecture patterns
- Critical: Security violations (e.g., hardcoded keys)

**4. Performance**
- Pass: No bottlenecks
- Minor: Optimizable (e.g., O(n²)→O(n log n))
- Major: Severe issues (e.g., blocking)
- Critical: Unusable performance

**5. Maintainability**
- Pass: Clear structure, ≤3 indent levels
- Minor: Long functions
- Major: High coupling, >4 indent levels
- Critical: Spaghetti code

**6. Security**
- Pass: No vulnerabilities
- Minor: Missing input validation
- Major: OWASP Top 10 risks
- Critical: Data leak/compromise risk

**7. Backward Compatibility**
- Pass: No breaking changes
- Minor: Deprecations with transition
- Major: Breaks internal APIs
- Critical: Breaks userspace/core APIs

Priority mapping: Critical→P0, Major→P1, Minor→P2, Pass→no issue
"""

REPORT_FORMAT_TEMPLATE = """### Report Format
Save review results to `report.md` using this exact format:

```markdown
# Review Report

## Status
approved | major_issues | minor_issues

## Issues Found

### P0 - Critical Issues
- [Issue with file:line, must fix]

### P1 - Major Issues
- [Issue with file:line, recommend fix]

### P2 - Minor Issues
- [Issue with file:line, optional fix]

## Suggestions
- [Improvement suggestion]

## Quality Rubric
Note: Provide brief explanation for any non-Pass scores.

| Dimension | Score | Notes |
|-----------|-------|-------|
| Completeness | Pass/Minor/Major/Critical | |
| Correctness | Pass/Minor/Major/Critical | |
| Best Practices | Pass/Minor/Major/Critical | |
| Performance | Pass/Minor/Major/Critical | |
| Maintainability | Pass/Minor/Major/Critical | |
| Security | Pass/Minor/Major/Critical | |
| Backward Compatibility | Pass/Minor/Major/Critical | |

## Summary
[1-3 paragraphs with file:line citations, risks, and next steps]
```
"""
